<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class zhuanti extends MY_Controller {
	//析构
	function __construct(){
		parent::__construct();
		//加载数据库
		$this->load->model('Zhuanti_model','_model');
	}
	public function index(){
		//专题商品
		$goods = $this->_model->getGoods();
		$ZhuanTiGoods = array();
		foreach ($goods as $key=>$item){
        	if ($key<9) {
        		$ZhuanTiGoods[0][]=$item;
        	}
        	if ($key>=9 && $key<18) {
        		$ZhuanTiGoods[1][]=$item;
        	}
        	if ($key>=18) {
        		$ZhuanTiGoods[2][]=$item;
        	}
        }
		//视图中的参数
		$data = array(
			'appid'      => $this->ceeconfigArray['appid'],
			'pf'         => $this->session->userdata('pf')?$this->session->userdata('pf'):"qzone",
			'userinfo'   => $this->userinfoArray,
			'controller' => 'zhuanti',
			'ZhuanTiGoods' => $ZhuanTiGoods
		);
		$this->load->view('common/header',$data);
		$this->load->view('zhuanti');//加载视图view
		$this->load->view('common/footer');
	}
	//商品点击
	public function AjaxGoodsClick(){
		/* -----------参数为空--------- */
		if (empty($_GET['id'])) {
			echo json_encode(array('ret'=>-1));//错误
			return false;
		}
		$affectNum = $this->_model->AjaxGoodsClick($_GET['id']);
		echo $affectNum;
		return false;
	} 
}
?>